import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { SaveExcelButton } from '../Common/options'
import { SuperviseTypeTree } from '../Common/Conversion'

export const SuperviseStatistics = async ({ url, ClientData, Permission }) => {
    const superviseTypeUuid = await SuperviseTypeTree()
    let data = {
        type: '监理工序',
        pageSize: 10,
        params: { pageIndex: 1 },
        hideInSearch: true,
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <SaveExcelButton
                type="primary"
                title="下载报告"
                api={API_LIST()['getSuperviseStatistics']}
                data={{ IsExport: 1 }}
            />,
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            {
                dataIndex: 'superviseTypeUuid',
                title: '工序类型',
                valueType: 'treeSelect',
                fieldProps: {
                    options: superviseTypeUuid,
                    fieldNames: { label: 'tableName', value: 'uuid' },
                },
                hideInTable: true,
                rules: true,
                width: 250,
            },
            {
                dataIndex: 'totalCount',
                title: '总数',
                valueType: 'inputNumber',
                rules: true,
                width: 100,
            },
            {
                dataIndex: 'submitted',
                title: '待审核',
                valueType: 'inputNumber',
                rules: true,
                width: 100,
            },
            {
                dataIndex: 'ok',
                title: '合格数',
                valueType: 'inputNumber',
                rules: true,
                width: 100,
            },
            {
                dataIndex: 'notOk',
                title: '不合格',
                valueType: 'inputNumber',
                rules: true,
                width: 100,
            },
            {
                dataIndex: 'percentd',
                title: '合格率',
                valueType: 'inputNumber',
                rules: true,
                width: 200,
                render: (_, { percentd }) => <div>{percentd * 100}%</div>,
            },
        ],
    }
    return data
}
